<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"
	import="xyz.xiangyushui.javaBean.membership.Reservation"
	import="java.util.List" import="java.text.SimpleDateFormat"
	import="java.util.Date"%>
<%@include file="/lib/common/basedir.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@include file="/lib/common/headerResource.html"%>

<!--sidebar-->
<link href="<%=basedir%>/lib/css/sidebar.css" rel="stylesheet">

<!--sweet-alert-->
<link rel="stylesheet" type="text/css"
	href="<%=basedir%>/lib/util/sweet-alert/sweet-alert.css">
<title>myReservation</title>

<style>
.rowGap {
	margin-top: 3em;
}
</style>
</head>
<body>
	<div class="container-fluid">
		<div class="row">
			<!--左侧导航-->
			<div class="col-sm-3 col-md-2 sidebar">
				<%@include file="../sidebar.jsp"%>
			</div>
			<!--右面板-->
			<div
				class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 rightPanel">
				<div class="col-md-10">
					<div class="row">
						<ul class="nav nav-tabs">
							<li role="presentation" ><a
								href="<%=basedir%>/member">所有甜品</a></li>
							<li role="presentation" class="active"><a
								href="<%=basedir%>/member/myReservation">我的预定</a></li>
						</ul>
					</div>

					<div class="table-responsive rowGap">
						<table class="table table-striped table-hover">
							<thead>
								<tr>
									<th>销售时间</th>
									<th>店铺号</th>
									<th>甜品</th>
									<th>数量</th>
								</tr>
							</thead>
							<tbody>

								<%
									@SuppressWarnings("unchecked")
																																	List<Reservation> rs=(List<Reservation>)request.getAttribute("reservations");
														if(rs!=null){
																																	if(rs.size()>0){
																																		for(int i=0;i<rs.size();i++){
																																			Reservation r=rs.get(i);
																																			String date_storeId=r.getDate_storeId();
																																			String[] parts=date_storeId.split("_");
								%>

								<tr>
									<td><%=new SimpleDateFormat("yyyy-MM-dd").format(new Date(Long.parseLong(parts[0])))%></td>
									<td><%=parts[1] %></td>
									<td><%=r.getCommodityIdName()%></td>
									<td><%=r.getQuantity()%></td>
									<td><span class="glyphicon glyphicon-minus delete<%=i%>"
										aria-hidden="true" role="button" data-toggle="tooltip"
										data-placement="bottom" title="取消订单"></span></td>
								</tr>

								<%
									} }}
								%>

							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- jquery and bootstrap js -->
	<%@include file="/lib/common/footerResource.html"%>
	<script src="<%=basedir%>/lib/util/sweet-alert/sweet-alert.js"></script>

	<script>
		$(document).ready(function() {
	<%if(rs!=null&&rs.size()>0){
		for(int i=0;i<rs.size();i++){%>
		
		$('.delete<%=i%>').on('click', function() {
				swal({
					title : "",
					text : "此操作不可逆,你确定要取消此次预定吗？",
					allowOutsideClick : true,
					showCancelButton : true,
					confirmButtonColor : "#DD6B55",
					confirmButtonText : "确认",
					cancelButtonText : "取消",
					closeOnConfirm : false
				}, function() {
					window.location.href = '<%=basedir%>/member/reservation/delete?id=<%=rs.get(i).getId()%>';
														});
											});
						});
	<%}}%>
		//tooltip
		$(function() {
			$("[data-toggle='tooltip']").tooltip();
		});
	</script>

</body>
</html>